home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: seebs@solon.com (Peter Seebach)
- Newsgroups: comp.lang.c,comp.lang.c.moderated,comp.programming.contests
- Subject: NEW CONTEST!
- Followup-To: comp.lang.c.moderated
- Date: 5 Feb 1996 08:45:02 -0600
- Organization: Usenet Fact Police (Undercover)
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4f555e$6tr@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
-
- *please notice and respect followups*
-
- Now, since I'm about to get the prize from the last contest to a post office
- for shipping, it's time for a ....
-
- NEW PROGRAMMING CONTEST!
-
- This is the 2nd comp.lang.c.moderated contest. Prize is TBD.
-
- The subject: Homework.
-
- The contest goals: We provide three typical questions - a stereotypical
- first year C programming take home test. Your goal: Provide the most
- misleading accurate answers possible.
-
- Requirements:
- 1. You must be able to convince the judge (me) that you have fulfilled the
- requirements of each problem.
- 2. Your code must run on the majority of likely platfroms, and contain no
- undefined behavior (that I or anyone else reading can detect.)
- 3. Your code must be utterly unacceptable as an answer, at least, from
- a first year student. :)
-
- Bonus points for partially true and completely misleading comments, bad style,
- or clever algorithms.
-
- I am using this contest idea because I had a lot of fun writing the posts
- I use as examples.
-
- Examples:
-
- 1. Compliant but missing the point.
-
- >In article <4e4cu4$95f@vixen.cso.uiuc.edu>, HOTARD <jhotard> wrote:
- >>I am writing a program that looks at a character and then determines if it is a
- >>letter or number. This program must use the switch command ...
-
- >main() {
- > int c, x, printf();
- > c = getchar();
- > switch (x = ((c = (unsigned char) c), /* try to ensure a legal char. */
- > ((!!isdigit(c)) << 1) | ((!!isalpha(c)) << 0)))
- > default:
- > printf(
- > (x == 0 ? "'\\x%x' is neither a letter nor a number.\n" :
- > (x == 1 ? "'%c' is a letter.\n" : (x == 2 ? "'%c' is a number.\n" :
- > (x == 3 ? "'%c' is both a letter and a number.\n" :
- > "'\\x%x' is odd.\n"))), c);
- > return 0;
- >}
-
- 2. Misleading.
- >>For each tyep listed below, explain what sort of object can be stored in
- >>variables of that type and igve 2 examples:
-
- >>a. char
-
- > A char holds an integer value. Examples:
-
- > char coal = 32;
- > char woman = 16;
-
- >>b. int
-
- > An int holds a numeric value. Examples:
-
- > int pi = 3.14159;
- > int i = sqrt(-1);
-
- >>c. float
-
- > A float variable can change during execution. Examples:
-
- > float f = 1, g = 3;
- > f = g; /* assigns g to f, causing f to 'float' */
-
- >>d. long int
-
- > A long int has more digits than an int. Examples:
-
- > long int ten = 00000012;
- > long int hex = 0x15;
-
- > You can enter a long using "0x" to mean hex.
-
- ---end examples
-
- Feel free to be twisted, confusing, or malicious. All answers must be in C.
- Answers must be conforming, and should be strictly conforming if at all
- possible.
-
- The questions:
- (Answer at least one; I will probably give a prize for the best answer to
- each question.)
-
- 1. Write a program which asks for the user's name, age, and any other
- information you want, and which prints a chatty greeting message, and
- writes the user's information to a file.
-
- 2. Write a function which compares two strings, ignoring case. You should
- use the islower() and toupper() commands. Write a small program which uses
- this function to compare its arguments.
-
- 3. Write a program which plays tic-tac-toe against itself. It should
- be good enough to draw consistently.
-
- -s
- --
- Peter Seebach - seebs@solon.com - Copyright 1995 Peter Seebach.
- C/Unix wizard -- C/Unix questions? Send mail for help. No, really!
- Using trn? Weird new newsgroup problem? I know the fix! Email me!
- The *other* C FAQ - ftp taniemarie.solon.com /pub/c/afq - Not A Flying Toy
-